package com.feihao.zhou.BlockingQueueDemo;

import java.util.concurrent.ArrayBlockingQueue;

public class ChiHuo implements Runnable {
    private ArrayBlockingQueue<String> arrayBlockingQueue;

    public ChiHuo(ArrayBlockingQueue<String> arrayBlockingQueue) {
        this.arrayBlockingQueue = arrayBlockingQueue;
    }

    @Override
    public void run() {
        while (true){
            try {
                Thread.sleep(2000);
                String take = arrayBlockingQueue.take();
                System.out.println("吃货吃了一个" + take);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
